﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WCFTrays
{
    public partial class WCFOutboxConfigControl : Form
    {
        WCFOutbox outbox;
        public WCFOutboxConfigControl(WCFOutbox newOutbox)
            :base()
        {
            InitializeComponent();
            outbox = newOutbox;
            textBoxName.Text = outbox._concreteName;
            textBoxConnString.Text = outbox.connString;
            textBoxHost.Text = outbox.hostUrl;
            textBoxSelectQuery.Text = outbox.selectMessageQuery;
        }

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (textBoxConnString.Text.Length == 0 || textBoxHost.Text.Length == 0 || textBoxSelectQuery.Text.Length == 0 || textBoxName.Text.Length == 0)
            {
                MessageBox.Show("Por favor complete todos los campos.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                outbox.connString = textBoxConnString.Text;
                outbox.hostUrl = textBoxHost.Text;
                outbox.selectMessageQuery = textBoxSelectQuery.Text;
                outbox.setConcreteOutboxName(textBoxName.Text);
                this.Dispose();
            }
            
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
